<?php
    class Admincp_Model_Webinfo extends Zend_Db_Table_Abstract
    {
        protected $_db;
		
		public function __construct()
		{
			$this->_db = Zend_Registry::get('db');
		}
        
        public function getEmailById($id)
        {
            $sql = $this->_db->select()
                            ->from('webinfo', array('email'))
                            ->where('id = ?', $id);
            $result = $this->_db->fetchOne($sql);
            return $result;
        }
        
        public function getWebinfoById($id)
        {
            $sql = $this->_db->select()
                            ->from('webinfo_language AS wl', array('footer'))
                            ->join('language AS l', 'wl.language_id = l.id', array('locale'))
                            ->where('wl.webinfo_id = ?', $id);
            $result = $this->_db->fetchAll($sql);
            return $result;
        }
        
        public function updateWebinfo($data, $id) {
            $where = $this->getAdapter()->quoteInto('id = ?', $id);
            $this->_db->update('webinfo', $data, $where);
        }
        
        public function updateWebinfoLanguage($data, $webinfo_id, $language_id) {
            $where = 'webinfo_id = '.$webinfo_id.' AND language_id = '.$language_id;
            $this->_db->update('webinfo_language', $data, $where);
        }
    }
